package com.wwj.admin.pay.controller;

import com.github.pagehelper.Page;
import com.wwj.core.wawa.entity.PlayerRecharge;
import com.wwj.core.wawa.service.IPlayerRechargeService;
import com.wwj.framework.controller.BaseController;
import com.wwj.framework.utils.Page2EasyUiData;
import com.wwj.framework.utils.ReturnData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("pay")
public class PayController extends BaseController {
    private final String INDEX = "/admin/pay/pay";

    @Resource
    private IPlayerRechargeService playerRechargeService;

    @RequestMapping(value={"","/","/index","/list"})
    public String index(){
        return INDEX;
    }

    @RequestMapping("/listData.json")
    @ResponseBody
    public ReturnData list(String search, int offset, int limit)throws Exception{
        Map<String,Object> params = new HashMap<String,Object>();
        if(null != search && !"".equals(search)) {
            search = new String(search.getBytes("ISO8859-1"), "UTF-8");
            params.put("search",search);
        }
        Page<PlayerRecharge> records = playerRechargeService.findByPage(offset, limit, params);
        return new ReturnData().success(Page2EasyUiData.format(records));
    }
}
